#ifndef _MYSQL_SESSION_H_
#define _MYSQL_SESSION_H_
#include "event_type.h"
#include "event.h"
#include "tcp_server.h"
#include "mysql.h"
#include <map>
#include <string>

class MysqlSession;

class MysqlSession: public TcpSession
{
public:	
	MysqlSession(boost::asio::io_service& io_service);
	virtual pointer clone();
	virtual void setUserGuid(uint64_t guid) 
		{ user_guid = guid; }
	virtual uint64_t getUserGuid()
		{ return user_guid; }
	virtual void start();
	virtual void handle_read(const boost::system::error_code& err,
			std::size_t bytes_transferred);
protected:
	virtual void onRegisterUrl(void *buffer);
	virtual void onRegisterUser(void *buffer);
	virtual void onRequestFriend(void *buffer);
	virtual void process_read();
	typedef std::map<E_EVENT_TYPE, boost::function<void (void*)> > HandleMap;
	HandleMap handles;
	uint64_t user_guid;
	char buf[MAX_EVENT_LENGTH];
	
	std::size_t buf_read;
};

#endif // _MYSQL_SESSION_H_

